package zhihui.mobile.manager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 张公铭 on 2017/7/3 0003.
 * 管理类观察者
 */

public class AllManagerObvs
{
    private static AllManagerObvs managerObvs;
    private List<IManager> list = new ArrayList<>();

    private synchronized static void createdIns()
    {
        if (managerObvs == null)
        {
            managerObvs = new AllManagerObvs();
        }
    }

    public static AllManagerObvs getInstance()
    {
        if (managerObvs == null)
        {
            createdIns();
        }
        return managerObvs;
    }

    public void addManager(IManager manager)
    {
        list.add(manager);
    }

    public void removeManager(IManager manager)
    {
        list.remove(manager);
    }


    public void logout()
    {
        for (IManager manager : list)
        {
            manager.clear();
        }
    }
}
